$(function($){
    $.post("../module/findMenu?id=admin",function(data){
        var modules = data.datas;
        var $menu = $("#menus");
        $.each(modules,function(i,d){
            if(!d.owner){
                var dlhtml = "<dl id='menu-"+d.id+"'>";
                dlhtml+="<dt>";
                dlhtml+="<i class='Hui-iconfont'>&#xe620;</i> "+d.name+"<i class='Hui-iconfont menu_dropdown-arrow'>&#xe6d5;</i>";
                dlhtml+="</dt>";
                dlhtml+="</dl>";
                $menu.append(dlhtml);
                var ddhtml = "<dd style='display: none;'>";
                ddhtml+="<ul id='menu-"+d.id+"-ul'>";
                ddhtml+="</ul>";
                ddhtml+="</dd>";
                $("#menu-"+ d.id).append(ddhtml);
            }else{
                var lihtml = "<li>";
                lihtml+="<a data-href='"+d.url+"' data-title='"+d.name+"' href='javascript:void(0)'>"+d.name+"</a>";
                lihtml+="</li>";
                $("#menu-"+ d.owner+"-ul").append(lihtml);
            }
        });
        //设置点击菜单的事件
        $(".Hui-aside").Huifold({
            titCell:'.menu_dropdown dl dt',
            mainCell:'.menu_dropdown dl dd',
            trigger:"click",
            className:"selected",
            speed:"normal"
        });
    });
});